﻿import com.dmotiko.general.*;
import com.dmotiko.prune.*;
import com.dmotiko.lib.*;
/**
 * ...
 * @author sminutoli
 */
class MainNewsContent extends BaseClip
{
	private var mcMask:MovieClip;
	private var mcBar:MovieClip;
	private var mcUp:MovieClip;
	private var mcDown:MovieClip;
	private var mcTrigger:MovieClip;
	private var mcDrag:MovieClip;
	private var mcContent:MovieClip;
	private var mcBack:MovieClip;
	private var mcHeader:MovieClip;
	private var aClips:Array;
		
	private function initClip():Void {
		mcContent = createEmptyMovieClip( "mcContent", this.getNextHighestDepth());
		mcContent._x = mcMask._x;
		mcContent._y = mcMask._y;
				
		mcDrag._btnup = mcUp;		
		mcDrag._btndown = mcDown;
		mcDrag._trigger = mcTrigger;
		mcMask._alpha = 10;
		ScrollerMovie.setScroll( mcContent, mcMask, mcDrag, mcBar );
		//NewsLoader.run("news.xml", this);
		NewsLoader.run("http://www.prune.com.ar/getnews.php", this);
				
		mcHeader.onRollOver = mcBack.onRollOver = function() {
			_parent._parent.showNews();
		}
		
	}
	
	private function refreshData(){
		
		aClips = new Array();
		var nY:Number = 0;
		mcContent.createEmptyMovieClip("content", 1);
		
		for( var i=0; i < data.length; i++){
			//chequeo si esa noticia está marcada para el home
			if( data[i].home ){
				var clip:MovieClip = mcContent.content.attachMovie( "MainNewItem", "MainNewItem"+i, mcContent.content.getNextHighestDepth());
				clip._y = nY;
				clip.nClip = i;
				clip.setData(data[i]);
				nY += clip._height + 5;
				aClips.push(clip);
			}
		}
		
	}
	
}